/** * Created : July 16, 2012 * * @author pquiring */ import java.awt.Dimension; import java.awt.GraphicsEnvironment; import java.awt.Rectangle; import javaforce.*; public class EditProjectProperties extends javax.swing.JDialog { /** * Creates new form EditProperties */ public EditProjectProperties(java.awt.Frame parent, boolean modal, ProjectPanel project) { super(parent, modal); initComponents(); setPosition(); this.project = project; videoRate.setValue(new Integer(project.config.videoRate)); v1001.setSelected(project.config.v1001); audioRate.setSelectedItem("" + project.config.audioRate); audioChannels.setValue(new Integer(project.config.audioChannels)); width.setText("" + project.config.width); height.setText("" + project.config.height); preview.setSelected(project.config.preview); for(int a=0;a<videoBitRates.length;a++) { if (project.config.videoBitRate == videoBitRates[a]) { vBitRate.setSelectedIndex(a); break; } } for(int a=0;a<audioBitRates.length;a++) { if (project.config.audioBitRate == audioBitRates[a]) { aBitRate.setSelectedIndex(a); break; } } } int videoBitRates[] = {8000000, 6000000, 4000000, 2000000, 1000000, 800000, 400000, 200000}; int audioBitRates[] = {256000, 192000, 128000, 64000, 32000}; /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel1 = new javax.swing.JLabel(); videoRate = new javax.swing.JSpinner(); jLabel2 = new javax.swing.JLabel(); audioRate = new javax.swing.JComboBox(); jLabel3 = new javax.swing.JLabel(); audioChannels = new javax.swing.JSpinner(); accept = new javax.swing.JButton(); cancel = new javax.swing.JButton(); jLabel4 = new javax.swing.JLabel(); width = new javax.swing.JTextField(); jLabel5 = new javax.swing.JLabel(); height = new javax.swing.JTextField(); preview = new javax.swing.JCheckBox(); jLabel6 = new javax.swing.JLabel(); vBitRate = new javax.swing.JComboBox(); jLabel7 = new javax.swing.JLabel(); aBitRate = new javax.swing.JComboBox(); v1001 = new javax.swing.JCheckBox(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Project Properties"); setResizable(false); jLabel1.setText("Frame Rate:"); videoRate.setModel(new javax.swing.SpinnerNumberModel(24, 1, 120, 1)); jLabel2.setText("Audio Rate:"); audioRate.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "48000", "44100", "22050", "11025", "64000", "32000", "16000", "8000", "96000", " " })); audioRate.setSelectedIndex(1); jLabel3.setText("Audio Channels:"); audioChannels.setModel(new javax.swing.SpinnerNumberModel(2, 1, 2, 1)); accept.setText("Accept"); accept.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { acceptActionPerformed(evt); } }); cancel.setText("Cancel"); cancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelActionPerformed(evt); } }); jLabel4.setText("Video Size:"); width.setText("640"); jLabel5.setText("x"); height.setText("480"); preview.setText("Generate Previews"); preview.setToolTipText("Generates Media Previews"); jLabel6.setText("Video BitRate:"); vBitRate.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "8M", "6M", "4M", "2M", "1M", "800k", "400k", "200k" })); vBitRate.setSelectedIndex(4); vBitRate.setToolTipText(""); jLabel7.setText("Audio BitRate:"); aBitRate.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "256k", "192k", "128k", "64k", "32k" })); aBitRate.setSelectedIndex(2); aBitRate.setToolTipText(""); v1001.setText("X 1000 / 1001"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1) .addComponent(jLabel2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(audioRate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addComponent(videoRate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(v1001)))) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(audioChannels, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(width, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel5))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(height, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(cancel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(accept) .addGap(12, 12, 12)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(preview) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel6) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(vBitRate, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGap(10, 10, 10)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel7) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(aBitRate, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()))) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(videoRate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(v1001)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(audioRate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(audioChannels, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4) .addComponent(width, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5) .addComponent(height, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel6) .addComponent(vBitRate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel7) .addComponent(aBitRate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(preview) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(accept) .addComponent(cancel)) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void cancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelActionPerformed dispose(); }//GEN-LAST:event_cancelActionPerformed private void acceptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_acceptActionPerformed try { project.config.videoRate = (Integer)videoRate.getValue(); project.config.v1001 = v1001.isSelected(); project.config.audioRate = Integer.valueOf((String)audioRate.getSelectedItem()); project.config.audioChannels = (Integer)audioChannels.getValue(); project.config.width = Integer.valueOf(width.getText()); project.config.height = Integer.valueOf(height.getText()); project.config.preview = preview.isSelected(); project.config.videoBitRate = videoBitRates[vBitRate.getSelectedIndex()]; project.config.audioBitRate = audioBitRates[aBitRate.getSelectedIndex()]; } catch (Exception e) { JF.showError("Error", "Exception:" + e); return; } dispose(); }//GEN-LAST:event_acceptActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JComboBox aBitRate; private javax.swing.JButton accept; private javax.swing.JSpinner audioChannels; private javax.swing.JComboBox audioRate; private javax.swing.JButton cancel; private javax.swing.JTextField height; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JCheckBox preview; private javax.swing.JCheckBox v1001; private javax.swing.JComboBox vBitRate; private javax.swing.JSpinner videoRate; private javax.swing.JTextField width; // End of variables declaration//GEN-END:variables private ProjectPanel project; private void setPosition() { Dimension d = getSize(); Rectangle s = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); setLocation(s.width/2 - d.width/2, s.height/2 - d.height/2); } }